<template>
    <div>
        <el-table
            v-loading="loading"
            ref="currencyTable"
            :data="tableData"
            stripe
            border
            style="width: 100%"
            @selection-change="getSelectVal"
        >
            <el-table-column
                type="selection"
                width="55"
                align="center"
            ></el-table-column>
            <el-table-column prop="kingDocCode" label="单据编码">
                <template slot-scope="scope">
                    {{ scope.row.kingDocCode || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="kingDocTypeId" label="单据类型">
                <template slot-scope="scope">
                    {{ scope.row.kingDocTypeId || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="customerId" label="客户">
                <template slot-scope="scope">
                    {{ scope.row.customerId || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="saleDept" label="销售部门">
                <template slot-scope="scope">
                    {{ scope.row.saleDept || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="saleDept" label="销售部门">
                <template slot-scope="scope">
                    {{ scope.row.saleDept || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="currency" label="币别">
                <template slot-scope="scope">
                    {{ scope.row.currency || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="deptId" label="	所属公司">
                <template slot-scope="scope">
                    {{ scope.row.deptId || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="deliveryAddress" label="交货地点">
                <template slot-scope="scope">
                    {{ scope.row.deliveryAddress || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="margin" label="保证金">
                <template slot-scope="scope">
                    {{ scope.row.margin || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="marginLevel" label="保证金比例" width="100">
                <template slot-scope="scope">
                    {{ scope.row.marginLevel || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="rate" label="汇款">
                <template slot-scope="scope">
                    {{ scope.row.rate || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="receivingParty" label="收货方">
                <template slot-scope="scope">
                    {{ scope.row.receivingParty || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="saleDate" label="日期">
                <template slot-scope="scope">
                    {{ scope.row.saleDate || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="valueTax" label="金额">
                <template slot-scope="scope">
                    {{ scope.row.valueTax || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="unpaidAmount" label="未收款金额">
                <template slot-scope="scope">
                    {{ scope.row.unpaidAmount || "--" }}
                </template>
            </el-table-column>
            <el-table-column prop="taxAmount" label="税额">
                <template slot-scope="scope">
                    {{ scope.row.taxAmount || "--" }}
                </template>
            </el-table-column>

            <el-table-column prop="isTax" label="是否含税">
                <template slot-scope="scope">
                    <el-tag type="success" v-if="scope.row.isTax === '0'"
                        >是</el-tag
                    >
                    <el-tag type="danger" v-else>否</el-tag>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getSaleList } from "@/api/system/sale";
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1, //当前页
            pageSize: 10, //每页条数
            total: 0,
            loading: false,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.pageSize = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.getDataList();
        },
        getSelectVal(val) {
            this.$emit("getSelectVal", val);
        },
        getDataList() {
            this.loading = true;
            getSaleList({ limit: this.pageSize, page: this.currentPage }).then(
                (res) => {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                    this.loading = false;
                }
            );
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
